package com.houweishi.module.postrecord.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.postrecord.domain.BizPostRecord;
import com.houweishi.module.postrecord.service.IBizPostRecordService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 调岗记录Controller
 * 
 * @author houweishi
 * @date 2023-02-25
 */
@RestController
@RequestMapping("/module/postrecord")
public class BizPostRecordController extends BaseController
{
    @Autowired
    private IBizPostRecordService bizPostRecordService;

    /**
     * 查询调岗记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPostRecord bizPostRecord)
    {
        startPage();
        List<BizPostRecord> list = bizPostRecordService.selectBizPostRecordList(bizPostRecord);
        return getDataTable(list);
    }

    /**
     * 导出调岗记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:export')")
    @Log(title = "调岗记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPostRecord bizPostRecord)
    {
        List<BizPostRecord> list = bizPostRecordService.selectBizPostRecordList(bizPostRecord);
        ExcelUtil<BizPostRecord> util = new ExcelUtil<BizPostRecord>(BizPostRecord.class);
        util.exportExcel(response, list, "调岗记录数据");
    }

    /**
     * 获取调岗记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizPostRecordService.selectBizPostRecordById(id));
    }

    /**
     * 新增调岗记录
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:add')")
    @Log(title = "调岗记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPostRecord bizPostRecord)
    {
        return toAjax(bizPostRecordService.insertBizPostRecord(bizPostRecord));
    }

    /**
     * 修改调岗记录
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:edit')")
    @Log(title = "调岗记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPostRecord bizPostRecord)
    {
        return toAjax(bizPostRecordService.updateBizPostRecord(bizPostRecord));
    }

    /**
     * 删除调岗记录
     */
    @PreAuthorize("@ss.hasPermi('module:postrecord:remove')")
    @Log(title = "调岗记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizPostRecordService.deleteBizPostRecordByIds(ids));
    }
}
